window.onload=function(){
	var head=document.getElementById("head");
	var pic=document.getElementsByClassName("pic");
	var yuan_son=document.getElementsByClassName("yuan_son");

	var num=0;
	function run(){
		for (var i = 0; i <pic.length ; i++) {
			pic[i].style.display="none";
			yuan_son[i].style,background="#000";
		};
			pic[num].style.display="block";
			yuan_son[num].style.background="#fff";
			num++;
			if (num==pic.length) {
				num=0;
			};
	}
	
	var time=setInterval(run, 500);
		head.onmouseover=function(){
			clearInterval(time);
		}
		
		head.onmouseout=function(){
			time=setInterval(run, 500);
		}

	for (var i =0; i <yuan_son.length; i++) {
		addEvent(i);
	};

	function addEvent(x){
		yuan_son.onclick=function(){
			num=x;
			run();
		}
	}
}